﻿using MediatR;
using SmartTracking.API.Read.Application.Commands.EWEQuery;
using SmartTracking.Domain.EWE;
using SmartTracking.ErrorCode;
using SmartTracking.Infrastructure.Interfaces;

namespace SmartTracking.API.Read.Application.CommandHandlers.EWEQuery
{
    public class GetEwematingsIdCommandHandler : IRequestHandler<GetEwematingsIdCommand, ApiResult<Ewematings>>
    {
        private readonly IBaseRepository<Ewematings> eRep;

        public GetEwematingsIdCommandHandler(IBaseRepository<Ewematings> eRep)
        {
            this.eRep = eRep;
        }

        public async Task<ApiResult<Ewematings>> Handle(GetEwematingsIdCommand request, CancellationToken cancellationToken)
        {
            ApiResult<Ewematings>result=new ApiResult<Ewematings>();
            result.Code = ApiEnum.查询成功;
            result.Message = "查询成功";

            var list =await eRep.GetByIdAsync(request.EwematingId);
            result.data = list;


            return await Task.FromResult(result);
        }
    }
}
